#!/usr/bin/python
# -*- coding: utf-8 -*-


import os
import sys

if __name__ == '__main__':
        args = sys.argv
        
        if len(args) != 3:
                print 'ERRO: need arguments,(source_dir newname_prevfix)'
                exit()


        s_dir = args[1];
        prevfix = args[2];      
        if os.path.isdir(s_dir):
                count = 1
                for sfile in os.listdir(s_dir):
                        if os.path.isfile(s_dir + os.sep + sfile):
                                (file_name, file_ext) = os.path.splitext(sfile)
                                if file_ext == '.jpg':
                                        os.rename(s_dir + os.sep + sfile, s_dir + os.sep + prevfix + str(count) + file_ext)
                                        count = count + 1

